<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head >
    <meta charset="UTF-8">
    <title>用户共享社区</title>
    <!-- Custom fonts for this template-->
    <link th:href="@{/vendor/fontawesome-free/css/all.min.css}" rel="stylesheet" type="text/css">
    <!-- Page level plugin CSS-->
    <link th:href="@{/vendor/datatables/dataTables.bootstrap4.css}" rel="stylesheet">
    <!-- Custom styles for this template-->
    <link th:href="@{/css/sb-admin.css}" rel="stylesheet">
    <!-- Bootstrap core JavaScript-->
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>
    <!-- Core plugin JavaScript-->
    <script th:src="@{/vendor/jquery-easing/jquery.easing.min.js}"></script>
    <!-- Page level plugin JavaScript-->
    <script th:src="@{/vendor/datatables/jquery.dataTables.js}"></script>
    <script th:src="@{/vendor/datatables/dataTables.bootstrap4.js}"></script>
    <!-- Custom scripts for all pages-->
    <script th:src="@{/js/sb-admin.min.js}"></script>
    <!-- Demo scripts for this page-->
    <script th:src="@{/js/demo/datatables-demo.js}"></script>
</head>
<body id="page-top">


<nav class="navbar navbar-expand navbar-dark bg-dark static-top">

    <a class="navbar-brand mr-1" th:href="@{/user/index}">日程云共享管理系统</a>


    <!-- Navbar -->
    <ul class="navbar-nav ml-auto ml-md-12">

        <div th:if="${session.loginUser!=null}">
            <p th:text="${session.loginUser.getUsername()}" style="color:white"> </p>
        </div>
        <li class="nav-item dropdown no-arrow">
            <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="fas fa-user-circle fa-fw"></i>
            </a>
            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userDropdown">
                <a class="dropdown-item" href="#">个人设置</a>
                <a class="dropdown-item" th:href="@{/reset-password}">修改密码</a>
                <div class="dropdown-divider"></div>
                <div th:if="${session.loginUser!=null}">
                    <a class="dropdown-item" th:href="@{/logout}" data-toggle="modal" data-target="#logoutModal">注销</a>
                </div>
            </div>
        </li>
    </ul>

</nav>

<div id="wrapper">

    <!-- Sidebar -->
    <ul class="sidebar navbar-nav">
        <li class="nav-item">
            <a class="nav-link" href="#">
                <i class="fas fa-fw fa-tachometer-alt"></i>
                <span>Dashboard</span>
            </a>
        </li>
        <li class="nav-item active">
            <a class="nav-link" th:href="@{/share/community}">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>用户共享社区</span></a>
        </li>
        <li class="nav-item ">
            <a class="nav-link" th:href="@{/user/toScheduleframework}">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>日程框架</span></a>
        </li>
        <li class="nav-item ">
            <a class="nav-link" th:href="@{/scheduletable/toScheduletable}">
                <i class="fas fa-fw fa-table"></i>
                <span>日程表</span></a>
        </li>
        <li class="nav-item ">
            <a class="nav-link" th:href="@{/scheduletemplate/toTemplate}">
                <i class="fas fa-fw fa-table"></i>
                <span>日程模版</span></a>
        </li>
        <li class="nav-item " shiro:hasRole="admin">
            <a class="nav-link" th:href="@{/admin/list}">
                <i class="fas fa-fw fa-table"></i>
                <span>用户列表</span></a>
        </li>
    </ul>

    <div id="content-wrapper">

        <div class="container-fluid">

            <!-- Breadcrumbs-->
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Dashboard</a>
                </li>
                <li class="breadcrumb-item active">用户共享社区</li>
            </ol>


            <!-- Page Content -->
            <!-- 日程框架部分-->
            <div class="card mb-3">
                <div class="card-header">
                    <i class="fas fa-table"></i>
                    日程框架
                    <!-- 搜索 -->
                    <form class="d-none d-md-inline-block form-inline ml-auto mr-0 mr-md-3 my-2 my-md-0" method="get" th:action="@{/share/searchFramework}">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2" name="value">
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="submit">
                                    <i class="fas fa-search"></i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="card-body">
                    <div class="table-responsive" style="height:250px;overflow-x:hidden;overflow-y:scroll;">
                        <table class="table table-bordered table-responsive-xl text-nowrap " >
                            <thead>
                                <tr>
                                    <th>id</th>
                                    <th>创建者</th>
                                    <th>日程框架名</th>
                                    <th>组织</th>
                                    <th>创建时间</th>
                                    <th>开始日期</th>
                                    <th>结束日期</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody th:each="user1:${msg.get('users1')}">
                                <tr th:each="framework:${user1.getScheduleframeworks()}">
                                    <th th:text="${framework.getId()}">id</th>
                                    <th th:text="${user1.getUsername()}">创建者</th>
                                    <th th:text="${framework.getName()}">日程框架名</th>
                                    <th th:text="${framework.getOrganization()}">组织</th>
                                    <th th:text="${#dates.format(framework.getCreateTime(),'yyyy-MM-dd HH:mm')}">创建时间</th>
                                    <th th:text="${#dates.format(framework.getStartDate(),'yyyy-MM-dd')}">开始日期</th>
                                    <th th:text="${#dates.format(framework.getEndDate(),'yyyy-MM-dd')}">结束日期</th>
                                    <th>
                                        <button class="btn btn-primary btn-sm fview_btn" th:attr="view-id=${framework.getId()}">查看</button>
                                        <a class="btn btn-primary btn-sm " th:href="@{'/share/copy/'+${framework.getId()}}">复制</a>
                                    </th>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>



            <!--日程表部分-->
            <div class="card mb-3">
                <div class="card-header">
                    <i class="fas fa-table"></i>
                    日程表
                    <!-- 搜索 -->
                    <form class="d-none d-md-inline-block form-inline ml-auto mr-0 mr-md-3 my-2 my-md-0" method="get" th:action="@{/share/searchTable}">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2" name="value">
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="submit">
                                    <i class="fas fa-search"></i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="card-body">
                    <div class="table-responsive" style="height:300px;overflow-x:hidden;overflow-y:scroll;">
                        <table class="table table-bordered table-responsive-md text-nowrap">
                            <thead>
                                <tr>
                                    <th>id</th>
                                    <th>创建者</th>
                                    <th>日程表名</th>
                                    <th>操作</th>
                            </tr>
                            </thead>
                            <tbody th:each="user2:${msg.get('users2')}">
                                <tr th:each="table:${user2.getScheduletables()}">
                                    <th th:text="${table.getId()}">id</th>
                                    <th th:text="${user2.getUsername()}">创建者</th>
                                    <th th:text="${table.getName()}">日程表名</th>
                                    <th>
                                        <button class="btn btn-primary btn-sm view_btn"  th:attr="view-id=${table.getId()}">查看</button>
                                        <a class="btn btn-primary btn-sm " th:href="@{'/share/copyTable/'+${table.getId()}}">复制</a>
                                    </th>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            </div>
        </div>
    </div>
    <!-- /.container-fluid -->

    <!-- Sticky Footer -->
    <footer class="sticky-footer">
        <div class="container my-auto">
            <div class="copyright text-center my-auto">
                <span>Copyright © Your Website 2019</span>
            </div>
        </div>
    </footer>

</div>
<!-- /.content-wrapper -->

</div>
<!-- /#wrapper -->

<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
</a>

<!-- Logout Modal-->
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">确定退出登录吗?</h5>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">如果您准备结束当前会话，请在下面选择“退出”。</div>
            <div class="modal-footer">
                <button class="btn btn-secondary" type="button" data-dismiss="modal">取消</button>
                <a class="btn btn-primary" th:href="@{/logout}">退出</a>
            </div>
        </div>
    </div>
</div>



</body>

<script>

    //点击查看日程表按钮，跳转页面
    $(document).on("click",".view_btn",function () {
        var scheduletableId=$(this).attr("view-id");
        $.ajax({
            success : function(msg){
                window.location.href="http://localhost:8088/scheduletable/view/"+scheduletableId;
            }
        });
    })

    //点击查看日程框架按钮，跳转页面
    $(document).on("click",".fview_btn",function () {
        var scheduleframeworkId=$(this).attr("view-id");
        $.ajax({
            success : function(msg){
                window.location.href="http://localhost:8088/user/view/"+scheduleframeworkId;
            }
        });
    })

</script>

</html>